<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>在线投票系统</title>
<link type="image/x-icon" href="images/yc.png" rel="shortcut icon"/>
<link type="text/css" rel="stylesheet" href="css/style.css" />

</head>
<body>
<div id="header" class="wrap">
	<img src="images/logo.gif" />
</div>
<div id="navbar" class="wrap">
	<div class="search">
	</div>
</div>
<div id="register" class="box">
	<h2>新用户注册</h2>
	<div class="content">
	   <form onsubmit="return false">
			<dl>
				<dt>用户名：</dt>
				<dd><input type="text" class="input-text" name="userName" v-model="uname"/></dd>
				<dt>密码：</dt>
				<dd><input type="password" class="input-text" name="password" v-model="pwd"/></dd>
				<dt>确认密码：</dt>
				<dd><input type="password" class="input-text" name="confirmPassword" v-model="cpwd"/></dd>
				<dt></dt>
				<dd><input type="submit" class="input-button" name="submit" value="" @click="reg" /></dd>
			</dl>
		</form>
		<div class="error"></div>
		<div class="error"></div>
	</div>
</div>
<div id="footer" class="wrap">
	憬荃 &copy; 版权所有
</div>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/axios.js"></script>
<script type="text/javascript" src="js/qs.js"></script>
<script type="text/javascript">
let app = new Vue({
	el: "#register",
	data: {
		uname:"",
		pwd:"",
		cpwd:""
	},
	methods: {
		reg: function(){
			if(this.uname == "" || this.pwd == "" || this.cpwd != this.pwd){
				alert("您输入的信息有误...");
				return;
			}
			
			axios.post("user/reg", qs.stringify({uname:this.uname, pwd:this.pwd})).then( rt => {
				if(rt.status == 200 || rt.data.code == 200){
					location.href="reg_success.html";
					return;
				}
				alert("注册失败,请稍后重试...");
			})
		}
	}
})
</script>
</body>
</html>
